

#import "BaseTabBarViewController.h"
#import "BaseNavigationController.h"
#import "HomeViewController.h"


@interface BaseTabBarViewController ()<UITabBarControllerDelegate>

@end

@implementation BaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    [self setupColor];
    [self setupViewController];
    // Do any additional setup after loading the view.
}

- (void)setupColor{
    self.tabBar.translucent = NO;
    self.tabBar.tintColor = ColorHex(@"#18CFF2");
    self.tabBar.unselectedItemTintColor = ColorHex(@"#B3B3B3");
    self.tabBar.backgroundImage = [UIImage imageWithColor:[UIColor whiteColor]];
    self.tabBar.backgroundColor = [UIColor whiteColor];
}

- (void)setupViewController{
    HomeViewController *vc1 = [[HomeViewController alloc] init];

    NSArray *controllerArray = @[vc1];
    NSArray *titles = @[@"首页"];
    NSArray *imgs = @[@"首页"];
    NSArray *selectimgs = @[@"首页_选中"];
    for (int i = 0; i < controllerArray.count; i++) {
        UIViewController *vc = controllerArray[i];
        vc.tabBarItem = [[UITabBarItem alloc] init];
        vc.tabBarItem.title = LS(titles[i]);
        vc.tabBarItem.image = [[UIImage imageNamed:imgs[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectimgs[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

        BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
        [self addChildViewController:nav];
    }
}

#pragma mark - UITabBarControllerDelegate
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    UINavigationController *navi = (UINavigationController *)viewController;
    return YES;
}

@end
